/*
 * @Author: zqx me_zqx@163.com
 * @Date: 2025-05-15 10:51:01
 * @LastEditors: zqx me_zqx@163.com
 * @LastEditTime: 2025-09-16 16:02:40
 * @FilePath: /XMate-h5/src/services/minutes/lateAttender.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { http } from "@/utils/http";

export function getLateAttenderApi(confId: string) {
  console.log(confId);
}

export function fetchAsrStore(confId: string) {
  return http.request({
    url: `/rest/api/conference/${confId}/asr/store`,
    method: "POST",
    useOriginRes: true
  });
}

/// 新增【客户】伙伴 模版
export const getOuterFiledPartnerAPI = () => {
  return http.request({
    url: "/rest/api/form/definition/fields?formCode=OUTER_PARTNER",
    method: "GET"
  });
};

/// 新增【内部】伙伴 模版
export const getInternalFiledPartnerAPI = () => {
  return http.request({
    url: "/rest/api/form/definition/fields?formCode=INTERNAL_PARTNER",
    method: "GET",
    useOriginRes: true
  });
};

// 删除客户角色
export function deleteCustomerRole(contactId: string, customerId: string) {
  return http.request({
    url: `/rest/api/xmate/customer/${customerId}/contact/${contactId}`,
    method: "DELETE",
  });
}

/// 修改客户角色
export function changeCustomerRole(
  confId: string,
  customerRoleId: string,
  parameter: { name?: string; title?: string; position?: string; role?: string }
) {
  return http.request({
    url: `/rest/api/conference/${confId}/salesmate/customerrole/${customerRoleId}`,
    method: "PUT",
    data: parameter,
    useOriginRes: true
  });
}

/// 添加客户角色
export function addCustomerRole(
  confId: string,
  parameter: { name?: string; title?: string; position?: string; role?: string }
) {
  return http.request({
    url: `/rest/api/conference/${confId}/salesmate/customerrole`,
    method: "POST",
    data: parameter,
    useOriginRes: true
  });
}

/// 修改内部用户
export function changeInternalEmployees(
  confId: string,
  internalPartnerId: string,
  parameter: { name?: string; position?: string }
) {
  return http.request({
    url: `/rest/api/conference/${confId}/salesmate/internalpartner/${internalPartnerId}`,
    method: "PUT",
    data: parameter,
    useOriginRes: true
  });
}

/// 添加内部用户
export function addInternalEmployees(
  confId: string,
  parameter: { name?: string; position?: string }
) {
  return http.request({
    url: `/rest/api/conference/${confId}/salesmate/internalpartner`,
    method: "POST",
    data: parameter,
    useOriginRes: true
  });
}

/// 新建联系人 【内部 非组织架构内】
export function createInternalAttendAPI(parameter: any) {
  return http.request({
    url: `/rest/api/v1/partners`,
    method: "POST",
    data: parameter,
  });
}

// 删除内部参会人【内部 非组织架构内】
export function deleteInternalAttendAPI(id: string) {
  return http.request({
    url: `/rest/api/v1/partners/${id}`,
    method: "DELETE",
  });
}

// 更新内部参会人【内部 非组织架构内】
// parameter: { name: string; fieldValues: [] }
export function updateInternalAttendAPI(id: string, parameter: any) {
  return http.request({
    url: `/rest/api/v1/partners/${id}`,
    method: "PUT",
    data: parameter,
  });
}

// 模糊查询内部参会人
export const searchInnerAttendAPI = (name: string) => {
  return http.request({
    url: "/rest/api/v1/partners/search",
    method: "GET",
    params: { name, size: 999 },
    useOriginRes: true
  });
};

// 查询推荐人
export const searchRecommendAPI = () => {
  return http.request({
    url: "/rest/api/participant/recommend",
    method: "GET",
  });
};

// 获取会议客户联系人/已有客户角色
export function getCustomerContactApi(confId: string) {
  return http.request({
    url: `/rest/api/conference/${confId}/customer/contact`,
    method: "GET",
    useOriginRes: true
  });
}

// 修改所有参会人姓名
export function updateAllAsrName(confId: string, data: any) {
  return http.request({
    url: `/rest/api/conference/${confId}/participant`,
    method: "PUT",
    data,
    useOriginRes: true
  });
}
// 修改单个人名
export function updateSingleAsrName(confId: string, data: any) {
  return http.request({
    url: `/rest/api/conference/${confId}/subtitle`,
    method: "PUT",
    data,
    useOriginRes: true
  });
}
export function updateAsrName(confId: string, data: any, isBatch = true) {
  return isBatch
    ? updateAllAsrName(confId, data)
    : updateSingleAsrName(confId, data);
}

// 标注参会人姓名
export function markUserAsrName(data) {
  const { confId, userId } = data;

  // 将path中的参数删除
  delete data.confId;
  delete data.userId;

  return http.request({
    url: `/rest/api/participant/mark/conference/${confId}/user/${userId}`,
    method: "PUT",
    data,
  });
}